package com.tencent.qf.bascic.controller;

import com.tencent.qf.bascic.controller.req.DataCollectRequest;
import com.tencent.qf.bascic.controller.req.DataReportRequest;
import com.tencent.qf.bascic.service.DataReportService;
import com.tencent.qf.common.aspect.annotation.ApiLog;
import com.tencent.qf.common.aspect.annotation.Signature;
import com.tencent.qf.common.exception.ErrorCode;
import com.tencent.qf.common.pojo.HttpResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author: p_haojiawu@tencent.com
 * @date: 2023-05-04 10:51
 **/

@RestController
@RequestMapping("/api/basic")
public class DataReportController {

    @Resource
    private DataReportService dataReportService;

    @PostMapping("/data/report")
    @ApiLog("数据上报")
    public HttpResult<Boolean> dataReport(@RequestBody @Valid DataReportRequest request){
        String errMsg = dataReportService.report(request);
        if("".equals(errMsg)) {
            return HttpResult.success(true);
        } else {
            return HttpResult.error(ErrorCode.BAD_REQUEST.getCode(), errMsg);
        }
    }
}
